﻿CREATE TABLE [dbo].[arhRulajeDoc] (
    [IDDocument]       BIGINT          NOT NULL,
    [ValoareLei]       DECIMAL (20, 2) DEFAULT ((0)) NOT NULL,
    [ValoareValuta]    DECIMAL (20, 2) DEFAULT ((0)) NOT NULL,
    [NumarDoc]         DECIMAL (18)    DEFAULT ((0)) NOT NULL,
    [DataDoc]          DATETIME        DEFAULT (getdate()) NOT NULL,
    [NumarNota]        VARCHAR (50)    DEFAULT ('') NOT NULL,
    [TipFormula]       SMALLINT        DEFAULT ((0)) NOT NULL,
    [IDJurnal]         INT             DEFAULT ((0)) NULL,
    [Observatii]       VARCHAR (200)   NULL,
    [xUser]            VARCHAR (50)    DEFAULT (suser_sname()) NOT NULL,
    [xHost]            VARCHAR (50)    DEFAULT (host_name()) NOT NULL,
    [xDate]            DATETIME        DEFAULT ((0)) NOT NULL,
    [CodUnitate]       SMALLINT        DEFAULT ((0)) NOT NULL,
    [An]               SMALLINT        DEFAULT ((0)) NOT NULL,
    [IDSursaFinantare] SMALLINT        NULL,
    [IDSectorBugetar]  SMALLINT        NULL,
    CONSTRAINT [PK_arhRulajeDoc] PRIMARY KEY CLUSTERED ([IDDocument] ASC),
    CONSTRAINT [CK_arhRulajeDoc_Tip_FORMULA] CHECK ([TipFormula]=(3) OR ([TipFormula]=(2) OR ([TipFormula]=(1) OR [TipFormula]=(0)))),
    CONSTRAINT [FK_arhRulajeDoc_Jurnale] FOREIGN KEY ([IDJurnal]) REFERENCES [dbo].[Jurnale] ([IDJurnal]),
    CONSTRAINT [FK_arhRulajeDoc_Unitati] FOREIGN KEY ([CodUnitate]) REFERENCES [dbo].[Unitati] ([CodUnitate])
);

